package com.rtech.app.client;

import java.util.Scanner;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainClient {

	public static void main(String[] args) {

		ApplicationContext context = new ClassPathXmlApplicationContext(
				"client-appConfig.xml");
		RestClient client = (RestClient) context.getBean("restClient");
		System.out.println("Check -- " + client);

		while (true) {
			try {
				System.out
						.print("Select option:\n 1 for Directory \n 2 for File Search \n 3 for exit \n>>>");

				Scanner sc = new Scanner(System.in);
				int i = sc.nextInt();
				String path = "";
				String result = "";
				switch (i) {
				case 1:
					path = sc.next();
					result = client.directorySearch(path);
					System.out.println("Result - " + result);
					break;
				case 2:
					path = sc.next();
					result = client.fileSearch(path);
					System.out.println("Result - " + result);
					break;
				case 3:
					System.exit(0);
					break;

				default:
					System.out.println("No Functionality for the Option");

				}

			} catch (Exception e) {
				System.out.println("Invalid Option");
			}
		}

	}
}
